package com.zhangxun.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhangxun.domain.Prod;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhangxun.domain.ProdChange;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author 张循
* @description 针对表【prod(商品)】的数据库操作Mapper
* @createDate 2023-01-01 18:04:15
* @Entity com.zhangxun.domain.Prod
*/
public interface ProdMapper extends BaseMapper<Prod> {

    @Select("select count(*) from prod where status = 0")
    int countByCountdition();


    @Update("update prod set total_stocks = total_stocks+#{count} where prod_id = #{prodId} and total_stocks+#{count} >= 0")
    void updateCountById(ProdChange prodChange);
}




